#include "gpio.h"
#include "uart0.h"
#include "tools.h"
#include "led.h"

extern char s[20];

void delay_ms(unsigned int ms)
{
	unsigned int i,j;
	for(i = 0; i < ms; i++)
		for(j = 0; j < 1800; j++);
}



int main()
{
	// 调用硬件初始化的函数
    hal_uart0_init();
    hal_led_init();
    
    uart_send_string("hello wan bo, this msg send from S5P6818");
    uart_send_string("\r\n");
	while(1)
	{
        uart_send_string("command: ");
        uart_recv_string();
        uart_send_char('\n');

        if (str_ncmp(s, "redon", 5) == 0) led_control(RED, ON);
        if (str_ncmp(s, "redoff", 6) == 0) led_control(RED, OFF);

        if (str_ncmp(s, "blueon", 6) == 0) led_control(BLUE, ON);
        if (str_ncmp(s, "blueoff", 7) == 0) led_control(BLUE, OFF);

        if (str_ncmp(s, "greenon", 7) == 0) led_control(GREEN, ON);
        if (str_ncmp(s, "greenoff", 8) == 0) led_control(GREEN, OFF);

        delay_ms(1000);
	}
	return 0;
}
